package com.example.cartmanage.cart

import androidx.lifecycle.MutableLiveData
import com.example.cartmanage.bean.CartListEntity
import com.example.cartmanage.chewei.entity.CheLiangEntity
import com.example.lib_base.mvvm.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class CartManageViewModel @Inject constructor(private val repo: CartManageRepo) : BaseViewModel() {
    val CartListSuccess = MutableLiveData<MutableList<CartListEntity>>()


    fun cartList() {
        httpRequest({ repo.apiService.getCartList() }, { CartListSuccess.postValue(it) })
    }
    val CheLiangSuccess = MutableLiveData<CheLiangEntity>()
    val editParkSuccess = MutableLiveData<CheLiangEntity>()
    fun cheLiang(licensePlate:String) {
        httpRequest({ repo.apiService.getParkManager(licensePlate) }, { CheLiangSuccess.postValue(it) })
    }
    fun editPark(id:Int,map:RequestBody) {
        httpRequest({ repo.apiService.editPark(id,map) }, { editParkSuccess.postValue(it) })
    }
}